/* **********************************************************************************
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* **********************************************************************************/

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Theme_Builder
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            try
            {
                Application.Run(new FormThemeBuilder());
            }
            catch(System.IO.FileNotFoundException fnfEx)
            {
                // For a file not found exception at this point, it probably means that the user doesn't
                //  have the PIA's installed.  Inform them that this crash is probably caused by that
                //  and send them to install the PIA's.
                DialogResult result = MessageBox.Show("The Theme Builder was unable to perform the desired action because it was unable to find some required files.  Please ensure that you have the Primary Interop Assemblies installed.\r\n\r\nDo you want to install the Primary Interop Assemblies?",
                    "File Not Found",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);

                // Launch a browser window to install the PIA's
                if (result == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start(@"http://www.microsoft.com/downloads/details.aspx?familyid=59daebaa-bed4-4282-a28c-b864d8bfa513&displaylang=en");
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Assert(false, ex.ToString());

                MessageBox.Show("The Theme Builder has done something wrong and will have to close.  We're sorry for any problems this may have caused and are working hard to fix this.",
                    "Sorry!",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}